<?php

//Village
class Form_Village_Create extends Base_Form
{
    public function init()
    {
		$this->addElements(array(
			// Add an Hidden element
            new Zend_Form_Element_Hidden('sid', array(
                'required'   => true,
				'value'      => 0,
				'decorators' =>array(
					'ViewHelper', 'Errors',
				),
                'validators' => array(
					array('validator'=> 'Int')
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('name', array(
                'required'   => true,
                'label'      => 'Village name:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'StringLength', 'options' => array(4,30))
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('vid', array(
                'required'   => true,
                'label'      => 'Village id:',
                'filters'    => array('StringTrim'),
                'description'=> 'Input a number between %min% and %max%',
                'validators' => array(
					array('validator' => 'Between', 'options' => array('min'=> 1, 'max'=> 99))
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('user', array(
                'required'   => true,
                'label'      => 'Village user:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'StringLength', 'options' => array(4,30))
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('area', array(
                'required'   => true,
                'label'      => 'Image area:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'Regex', 'options' => "/^\d{1,4}(,\d{1,4}){3}$/"),
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('population', array(
                'required'   => true,
                'label'      => 'Population:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'Int')
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('popu_women', array(
                'required'   => true,
                'label'      => 'Women:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'Int')
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('popu_flow', array(
                'required'   => true,
                'label'      => 'Flow:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'Int')
                )
            )),
			// Add an username element
            new Zend_Form_Element_Text('master', array(
                'required'   => true,
                'label'      => 'Village master:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'StringLength', 'options' => array(5,12))
                )
            )),
			// Add an username element
            new Zend_Form_Element_Textarea('intro', array(
                'required'   => true,
                'label'      => 'Intro:',
                'filters'    => array('StringTrim'),
                'validators' => array(
					array('validator' => 'StringLength', 'options' => array(30,255))
                )
            )),
        ));

        $this->addDisplayGroup(
            array('name','vid','user','area','population','popu_women','popu_flow', 'master', 'intro'), 'village',
			array(
				'legend' => 'Village'
			)
		);
    }
}
